package cn.rdq.service.impl;

import cn.rdq.api.po.User;
import cn.rdq.api.vo.LoginUser;
import cn.rdq.dao.UserMapper;
import cn.rdq.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User loginByUsernameAndPassword(LoginUser loginUser) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.select("username", "password");
        wrapper.eq("username", loginUser.getUsername())
                .eq("password", loginUser.getPassword());
        return getOne(wrapper);
    }
}
